import java.util.Iterator;
import java.util.List;

import fr.u.psud.polytech.controller.EntrepotManager;
import fr.u.psud.polytech.controller.UserManager;
import fr.u.psud.polytech.database.Entrepot;
import fr.u.psud.polytech.database.User;

public class MainUserManager {
	public static void main(String args[]){
		UserManager um = new UserManager ();
		EntrepotManager em = new EntrepotManager();
		
		um.addUser("toto","titi", "test", "ttoto", "password",em.getEntrepot(1));
		um.addUser("haddock","capitaine", "capitaine", "chaddock", "password",em.getEntrepot(2));
		um.addUser("tintin","journaliste", "emmerdeur", "jtintin", "password",em.getEntrepot(3));
//		
		List<User> list = um.getUsers(); 
		
		User p  = um.getUser("chaddock");
		
		System.out.println("----------------------------");
		System.out.print(p.getId()+" : ");
		System.out.print(p.getNom()+ " : ");
				
		System.out.println("----------------------------");
		
		Iterator<User> it = list.iterator();
		System.out.println("Liste complète ");
		while(it.hasNext()){
			User u = it.next();
			System.out.print(u.getId()+" : ");
			System.out.print(u.getNom()+ " : ");
			System.out.println(u.getEntrepot().getNom());
		}
		
		list = um.getUsers(1,3);
		
		it = list.iterator();
		System.out.println("Première page liste paginée par 3");
		while(it.hasNext()){
			User u = it.next();
			System.out.print(u.getId()+" : ");
			System.out.print(u.getNom()+ " : ");
			System.out.println(u.getEntrepot().getNom());
		}
		
		
		
		
	}
}
